package qmm.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcUtil {
	
	//ȡ
	public static Connection getConnection(){
		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/qmm?characterEncoding=utf8&useSSL=false","root","admin");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	//װ
	public static int update(String sql){
		int n = 0;
		try {
			Connection conn = getConnection();
			Statement st = conn.createStatement();
			n = st.executeUpdate(sql);			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return n;
	}
}
